#include<iostream>
#include<string>
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		string ans;
		int d;
		cin >> d;
		for (int i = 9; i >= 1; i--) {
			if (d >= i) {
				ans = (char)(i + '0') + ans;
				d -= i;
			}
		}
		cout << ans << endl;
	}
	return 0;
}